﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;

namespace WpfApplication1
{
    class ketnoi
    {
        public void insertData(int id, String name)
        {
                    SqlConnection conn = new SqlConnection();
        conn. ConnectionString="Data Source=(local);Initial Catalog=sale; User Id=sa; Password=sa";                 
        conn.Open();
        SqlCommand cmd = new SqlCommand("insert into Customers values("+id.ToString()+",'"+name+"')", conn);
       cmd.ExecuteNonQuery();
        conn.Close();

        }
        public void delete(int id)
        {
                    SqlConnection conn = new SqlConnection();
        conn. ConnectionString="Data Source=(local);Initial Catalog=sale; User Id=sa; Password=sa";                 
        conn.Open();
        SqlCommand cmd = new SqlCommand("delete  from Customers where id = "+id.ToString(), conn);
        cmd.ExecuteNonQuery();
        conn.Close();

        }
        public void update(int id, String name)
        {
            SqlConnection conn = new SqlConnection();
        conn. ConnectionString="Data Source=(local);Initial Catalog=sale; User Id=sa; Password=sa";                 
        conn.Open();
        SqlCommand cmd = new SqlCommand("update customers set name='"+name+"' where id="+id.ToString()+"", conn);
        cmd.ExecuteNonQuery();
        conn.Close();

        }
    }
}
